package com.hipac.qs.quartz;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.Date;

/**
 * Created by xiaogu on 2017/3/3.
 */
public class MyJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        System.out.println("I'm doing my job " + new Date());
        /**
         * context 是任务的上下文 可以获取很多东西 比如jobDetail
         */
        JobDetail jobDetail = context.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        System.out.println("Generating report - " + jobDetail.getKey().getName()
                + ", group =" + jobDetail.getKey().getGroup()
                + ", type =" + jobDataMap.get("type"));

        throw new JobExecutionException();
    }
}
